<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>提现账户换绑</title>
    <link rel="stylesheet" href="css/amazeui.min.css" />
    <link rel="stylesheet" href="css/app.css" />
    <link rel="stylesheet" href="css/swiper-3.3.1.min.css" />
    <script src="js/amazeui.min.js" type="text/javascript"></script>
    <script src="js/jquery.min.js" type="text/javascript"></script>
    <style>
        body {
            max-width: 640px;
            margin: 0 auto;
            font-size: 10px;
        }

        * {
            box-sizing: border-box;
        }

        [class*=am-u-] {
            padding: 0;
        }

        .am-u-sm-3 {
            text-align: center;
        }

        .am-u-sm-3 span {
            font-size: 14px;

        }

        .am-u-sm-9 input {
            font-size: 14px;
            border: none;
            width: 90%;
            line-height: 30px;
        }

        .am-u-sm-9 select {
            font-size: 14px;
        }

        .jj {
            line-height: 28px;
            padding: 0 10px;
            font-size: 14px;
        }

        .diqu select {
            font-size: 14px;
            width: 32%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
    </style>
</head>

<body>
    <!--头部-->
    <header class="am-u">
        <div class="am-u-sm-12 head_nav" style="margin:0;">
            <div class="am-u-sm-2 am-vertical-align" style="text-align: center;">
                <a href="Cashaccount.html">
                    <img src="img/return@2x.png" class="am-vertical-align-middle" alt="" />
                </a>
            </div>
            <div class="am-u-sm-8 head_text">
                提现账户换绑
            </div>
            <div class="am-u-sm-2">

            </div>
        </div>
    </header>
    <div style="clear: both;"></div>
    <div class="am-u">
        <div style="padding: 10px;font-size: 13px;color: #BFBEC3;">
            *银行卡信息（必填）
        </div>
        <div class="am-u-sm-12" style="padding: 10px 0 10px 0;border-bottom: 1px solid #BFBEC3;">
            <div class="am-u-sm-3">
                <span style="line-height:30px;">卡号</span>
            </div>
            <div class="am-u-sm-9">
                <input id="accountNo" type="text" placeholder="银行卡号" />
            </div>
        </div>
        <div class="am-u-sm-12" style="padding: 10px 0 10px 0;border-bottom: 1px solid #BFBEC3;">
            <div class="am-u-sm-3">
                <span>所属银行</span>
            </div>
            <div class="am-u-sm-9">
                <select id="cardName" style="color:#333;">
                    <option value="">请选择银行</option>
                </select>
            </div>
        </div>
        <div class="am-u-sm-12" style="padding: 10px 0 10px 0;border-bottom: 1px solid #BFBEC3;">
            <div class="am-u-sm-3">
                <span>地区</span>
            </div>
            <div class="am-u-sm-9 diqu">
                <select id="cmbProvince" name="cmbProvince"></select>
                <select id="cmbCity" name="cmbCity"></select>
                <select id="cmbArea" name="cmbArea"></select>
            </div>
        </div>
        <div class="am-u-sm-12" style="padding: 10px 0 10px 0;border-bottom: 1px solid #BFBEC3;">
            <div class="am-u-sm-3">
                <span>开户行</span>
            </div>
            <div class="am-u-sm-9">
                <span id="openBranch" style="font-size:14px;overflow: hidden;text-overflow:ellipsis;white-space: nowrap;width:90%;display:inline-block;">请选择开户行（如集美支行）</span>
            </div>
        </div>
        <div style="clear: both;"></div>
        <div style="padding: 10px;font-size: 13px;color: #BFBEC3;padding-bottom: 0;">
            *请填写持卡人信息(必填)，银行账户将默认成为您的提现账户
        </div>
        <div class="am-u-sm-12" style="padding: 10px 0 10px 0;border-bottom: 1px solid #BFBEC3;">
            <div class="am-u-sm-3">
                <span>持卡人</span>
            </div>
            <div class="am-u-sm-9">
                <span id="accountName" style="font-size:14px;color:#C8C8CA"></span>
            </div>
        </div>
        <div class="am-u-sm-12" style="padding: 10px 0 10px 0;border-bottom: 1px solid #BFBEC3;">
            <div class="am-u-sm-3">
                <span>身份证</span>
            </div>
            <div class="am-u-sm-9">
                <span id="idCard" style="font-size:14px;color:#C8C8CA"></span>
            </div>
        </div>
        <div class="am-u-sm-12" style="padding: 5px 0 5px 0;border-bottom: 1px solid #BFBEC3;">
            <div class="am-u-sm-3">
                <span style="line-height:30px;">手机号</span>
            </div>
            <div class="am-u-sm-9">
                <input id="phone" type="text" placeholder="银行预留手机号" />
            </div>
        </div>
        <div class="am-u-sm-12" style="border-bottom: 1px solid #BFBEC3;padding: 10px 0 10px 0;">
            <div class="am-u-sm-3" style="text-align: center;padding-top: 2px;">
                <div style="font-size: 13px;">验证码</div>
            </div>
            <div class="am-u-sm-4" style="font-size: 13px;padding: 0;">
                <input id="code" type="text" placeholder="输入验证码" style="width:100%;border: none;" />
            </div>
            <div class="am-u-sm-5" style="text-align: center;">
                <button id="huoqu_btn" type="button" style="outline:none;color:#41A0F0;border: none;font-size: 13px;background: #fff;">获取验证码</button>
            </div>
        </div>
    </div>
    <div style="clear: both;"></div>
    <div style="padding-top: 15px;text-align: center;">
        <button class="am-btn" id="hb_btn" type="button" style="width: 80%;border-radius: 5px;background: #0165C7;color: #fff;">完成</button>
    </div>
    <div class="am-container" style="display:none;position:fixed;top:0;left:0;background:#fff;width:100%;height:100%;padding:0;  ">
        <header class="am-u">
            <div class="am-u-sm-12 head_nav" style="margin:0;">
                <div class="am-u-sm-2 am-vertical-align" style="text-align: center;">
                    <img src="img/return@2x.png" class="am-vertical-align-middle" onclick="jk()" alt="" />
                </div>
                <div class="am-u-sm-8 head_text">
                    支行搜索
                </div>
                <div class="am-u-sm-2">

                </div>
            </div>
        </header>
        <div class="am-u">
            <div class="am-u-sm-12" style="margin-top: 10px;">
                <div class="am-u-sm-10" style="padding:0 5px;">
                    <input type="text" id="words" style="outline:none;width:100%;line-height: 25px;border-radius: 5px;padding-left:5px;font-size:14px;">
                </div>
                <div class="am-u-sm-2" style="padding:0;">
                    <span id="search" style="padding:3px 5px;display: inline-block;background:#41A0F0;border-radius: 5px;color:#fff;font-size:14px;">搜索</span>
                </div>
            </div>
        </div>
        <div class="am-u" id="zh_list">
            <div class="jj">看哈看上的健康</div>
            <div class="jj">看哈看上的健康</div>
        </div>
    </div>
    <script src="js/jquery-1.11.3.js"></script>
    <script src="js/loading.js"></script>
    <script src="js/searchCity.js"></script>
    <script type="text/javascript">
        addressInit('cmbProvince', 'cmbCity', 'cmbArea');
    </script>
    <script>
        var token1 = sessionStorage['token'];
        $("#idCard").html(sessionStorage['idCard']);
        $("#accountName").html(sessionStorage['accountName']);
        //                    获取银行列表
        $.ajax({
            type: 'POST',
            url: "http://www.rice.com/app/api/h5_access",
            contentType: "application/x-www-form-urlencoded; charset=utf-8",
            datatype: "JSON",
            data: {
                method: "get_bank"
            },
            success: function (data) {
                var data1 = JSON.parse(data);
                if (data1.status === 1) {
                    var html = "<option value=''>请选择银行</option>";
                    for (var i in data1.data.bank_data) {
                        html += "<option bank_code='" + data1.data.bank_data[i].bank_code +
                            "' bank_simple_code='" + data1.data.bank_data[i].bank_simple_code + "'>" +
                            data1.data.bank_data[i].bank_name + "</option>";
                    }
                    $("#cardName").html(html);
                } else if (Number(data1.status) == 2) {
                    alert(data1.message);
                    window.location.href = "login.html";
                } else {
                    alert(data1.message);
                }
            }
        });
        //                      判断能不能打开支行搜索
        $("#openBranch").on("click", function () {
            var cardName1 = $("#cardName").find("option:selected").text();
            if (cardName1 == "请选择银行") {
                alert("请先选择银行");
                return false;
            } else {
                $(".am-container").css("display", "block");
                var words1 = $("#cardName").find("option:selected").text();
                var bank_simple_code1 = $("#cardName").find("option:selected").attr("bank_simple_code");
                $.ajax({
                    type: 'POST',
                    url: "http://www.rice.com/app/api/h5_access",
                    contentType: "application/x-www-form-urlencoded; charset=utf-8",
                    datatype: "JSON",
                    data: {
                        method: "get_bank_branch",
                        words: words1,
                        bank_simple_code: bank_simple_code1
                    },
                    success: function (data) {
                        var data1 = JSON.parse(data);
                        if (data1.status === 1) {
                            var html = "";
                            for (var i in data1.data.bank_data) {
                                html += "<div class='jj' bank_code='" + data1.data.bank_data[i].bank_code +
                                    "'>" + data1.data.bank_data[i].bank_name + "</div>";
                            }
                            $("#zh_list").html(html);
                            $(".jj").on("click", function () {
                                $("#openBranch").html($(this).html());
                                $("#openBranch").attr("bank_code", $(this).attr("bank_code"));
                                $(".am-container").css("display", "none");
                            })
                        } else if (Number(data1.status) == 2) {
                            alert(data1.message);
                            window.location.href = "login.html";
                        } else {
                            alert(data1.message);
                        }
                    }
                });
            }
        })
        //                      隐藏支行搜索
        function jk() {
            $(".am-container").css("display", "none");
        }
        //                      支行搜索
        $("#search").on("click", function () {
            var words1 = $("#words").val();
            var bank_simple_code1 = $("#cardName").find("option:selected").attr("bank_simple_code");
            $.ajax({
                type: 'POST',
                url: "http://www.rice.com/app/api/h5_access",
                contentType: "application/x-www-form-urlencoded; charset=utf-8",
                datatype: "JSON",
                data: {
                    method: "get_bank_branch",
                    words: words1,
                    bank_simple_code: bank_simple_code1
                },
                success: function (data) {
                    var data1 = JSON.parse(data);
                    if (data1.status === 1) {
                        var html = "";
                        for (var i in data1.data.bank_data) {
                            html += "<div class='jj' bank_code='" + data1.data.bank_data[i].bank_code +
                                "'>" + data1.data.bank_data[i].bank_name + "</div>";
                        }
                        $("#zh_list").html(html);
                        $(".jj").on("click", function () {
                            $("#openBranch").html($(this).html());
                            $("#openBranch").attr("bank_code", $(this).attr("bank_code"));
                            $(".am-container").css("display", "none");
                        })
                    } else if (Number(data1.status) == 2) {
                        alert(data1.message);
                        window.location.href = "login.html";
                    } else {
                        alert(data1.message);
                    }
                }
            });
        })
        //                      验证码
        $("#huoqu_btn").on("click", function () {
            var phone1 = $("#phone").val();
            if (phone1 == "" || phone1 == null) {
                alert("请输入手机号");
                return false;
            }
            $.ajax({
                type: 'POST',
                url: "http://www.rice.com/app/api/h5_access",
                contentType: "application/x-www-form-urlencoded; charset=utf-8",
                datatype: "JSON",
                data: {
                    method: "readdwallet_sendmsg",
                    phone: phone1
                },
                success: function (data) {
                    var data1 = JSON.parse(data);
                    console.log(data);
                    if (data1.status === 1) {
                        var time = 180;
                        $('#huoqu_btn').html(time + "秒后重发").attr('disabled', true);
                        setInterval(function () {
                            time--;
                            if (time === 0) {
                                $('#huoqu_btn').html("发送验证码").attr('disabled', false);

                            } else if (time > 0) {
                                $('#huoqu_btn').html(time + "秒后重发").attr('disabled', true);
                            }
                        }, 1000);
                    } else if (Number(data1.status) == 2) {
                        alert(data1.message);
                        window.location.href = "login.html";
                    } else {
                        alert(data1.message);
                    }
                }
            });
        })
        $("#hb_btn").on("click", function () {
            var accountNo1 = $("#accountNo").val();
            var cardName1 = $("#cardName").find("option:selected").text();
            var bankCode1 = $("#cardName").find("option:selected").attr("bank_code");
            var cmbProvince1 = $("#cmbProvince").find("option:selected").text();
            var cmbCity1 = $("#cmbCity").find("option:selected").text();
            var cmbArea1 = $("#cmbArea").find("option:selected").text();
            var openBranch1 = $("#openBranch").html();
            var openBranch_code1 = $("#openBranch").attr("bank_code");
            var phone1 = $("#phone").val();
            var code1 = $("#code").val();
            if (!accountNo1) {
                alert("请输入卡号");
                return false;
            }
            if (cardName1 == "请选择银行") {
                alert("请先选择银行");
                return false;
            }
            if (openBranch1 == "请选择开户行（如集美支行）") {
                alert("请选择开户行");
                return false;
            }
            if (!phone1) {
                alert("请输入手机号");
                return false;
            }
            if (!code1) {
                alert("请输入验证码");
                return false;
            }
            var data = {};
            data.method = "readdwallet";
            data.token = token1;
            data.accountNo = accountNo1;
            data.province_name = cmbProvince1;
            data.city_name = cmbCity1;
            data.county_name = cmbArea1;
            data.bankCode = bankCode1;
            data.bankName = cardName1;
            data.openBranch_code = openBranch_code1;
            data.openBranch = openBranch1;
            data.phone = phone1;
            data.code = code1;
            $.ajax({
                type: 'POST',
                url: "http://www.rice.com/app/api/h5_access",
                contentType: "application/x-www-form-urlencoded; charset=utf-8",
                datatype: "JSON",
                data: data,
                success: function (data) {
                    var data1 = JSON.parse(data);
                    console.log(data1);
                    if (data1.status === 1) {
                        alert(data1.message);
                    } else if (Number(data1.status) == 2) {
                        alert(data1.message);
                        window.location.href = "login.html";
                    } else {
                        alert(data1.message);
                    }
                }
            });
        })
    </script>
</body>

</html>